<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" %>
<%@ page import="com.study.system.user.domain.User" %>
<%@ page import="com.study.system.user.service.impl.UserServiceImpl" %>
<%@ page import="com.study.system.user.domain.UserDept" %>
<%@ page import="com.study.system.utils.DataUtils" %>
<%@taglib prefix="c" uri="http://java.sun.com/jstl/core_rt" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" deferredSyntaxAllowedAsLiteral="true" %>
<html>
<head>
    <meta charset="UTF-8">
    <title>打卡管理系统</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/css/bootstrap.min.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/css/bootstrap-theme.min.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/css/bootstrap-admin-theme.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/css/bootstrap-admin-theme.css">

    <script src="${pageContext.request.contextPath}/static/js/bootstrap.min.js"></script>
    <script src="${pageContext.request.contextPath}/static/js/bootstrap-dropdown.min.js"></script>


</head>
<%--导入js--%>
<script src="${pageContext.request.contextPath}/static/js/axios-0.18.0.js"></script>

<script src="${pageContext.request.contextPath}/static/js/bootstrap.min.js"></script>

<%@include file="admin_header.jsp" %>
<body class="bootstrap-admin-with-small-navbar">
<%
    List<UserDept> userDeptList = new UserServiceImpl().selectallUserAndDept();
%>
<div class="container">
    <div class="row">
        <%@include file="admin_means.jsp" %>

        <div class="col-md-10">
            <div class="row">
                <div class="col-lg-12">
                    <div class="panel panel-default bootstrap-admin-no-table-panel">
                        <div class="panel-heading">
                            <div class="text-muted bootstrap-admin-box-title">用户管理</div>
                        </div>
                        <div class="bootstrap-admin-no-table-panel-content bootstrap-admin-panel-content collapse in">
                            <form class="form-horizontal" action="#" method="post">
                                <div class="col-lg-3 form-group">
                                    <button type="button" class="btn btn-primary" id="btn_add" data-toggle="modal"
                                            data-target="#addModal">添加用户
                                    </button>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-lg-12">
                    <table id="data_list" class="table table-hover table-bordered" cellspacing="0" width="100%">
                        <thead>
                        <tr>
                            <td>编号</td>
                            <th>账号</th>
                            <th>姓名</th>
                            <th>入职时间</th>
                            <th>部门</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <%
                            for (UserDept userDept : userDeptList) {
                        %>
                        <tbody>
                        <td><%= userDept.getId() %>
                        </td>
                        <td><%= userDept.getUsername() %>
                        </td>
                        <td><%= userDept.getName() %>
                        </td>
                        <td><%= DataUtils.getStringDate(userDept.getDate())%>
                        </td>
                        <td><%= userDept.getDept() %>
                        </td>
                        <td>
                            <button type="button" class="btn btn-warning btn-xs" data-toggle="modal"
                                    id="btn_update" onclick="showInfo2(<%= userDept.getId() %>)">修改
                            </button>
                            <button type="button" class="btn btn-danger btn-xs"
                                    onclick="deletebook(<%= userDept.getId() %>)">删除
                            </button>
                        </td>
                        </tbody>
                        <%} %>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    function showInfo2(id) {
        location.href = "${pageContext.request.contextPath}/user/updatetojsp?id=" + id;
    }

    function deletebook(id) {
        con = confirm("是否删除?");
        if (con == true) {
            location.href = "${pageContext.request.contextPath}/user/delUser?id=" + id;
        }
    }
</script>
</div>
</body>
</html>